﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NLog.Web.LayoutRenderers;
using T.S.BaseData.Api.AppClinet.Commend.Goods;
using T.S.BaseData.Api.Dto.Goods;
using T.S.BaseData.ErrorCode;

namespace T.S.BaseData.Api.Controllers
{
    /// <summary>
    /// 商品
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class GoodsController : ControllerBase
    {
        private readonly IMediator mediator;

        public GoodsController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加商品基本信息的接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> GoodsAdd(GoodsAddCommand request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 显示商品的接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<ShowGoodsDto>>> GoodsShow([FromQuery]GoodsShowCommand request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 商品基本信息显示接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaging<ShowBasicinfoDto>> BasicinfoShow([FromQuery]BasicinfoShowCommand request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 添加商品基本信息接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> BasicinfoAdd(BasicinfoAddCommand request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 删除商品基本信息接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> BasicinfoDel(BasicinfoDelCommand request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 根据详情跳转到的页面
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaging<GetBasicinfoDto>> BasicinfoGet([FromQuery]BasicinfoGetCommand request)
        {
            return mediator.Send(request);
        }

    }
}
